<?php
mysql_connect("127.0.0.1","root","sd2013");
mysql_select_db("mathRomp");
$response = '';
if($_POST['password'] == $_POST['passwordConfirm']){
  $q=mysql_query("SELECT * From `Teachers` where `username` = '".$_POST['username']."'");
  while($d=mysql_fetch_assoc($q)){
    $output[]=$d;
  }
  if($output == null){
    $q2=mysql_query("INSERT INTO `Teachers`(`teacherId`, `username`, `password`, `email`, `name`) VALUES (NULL,'".$_POST['username']."','".$_REQUEST['password']."','".$_REQUEST['email']."','".$_POST['name']."')");
    while($e=mysql_fetch_assoc($q2)){
      $output2[]=$e;
    }
    //print(json_encode($output2));
    $response = "you have successfully registered";
  }else{
    $response = "username already taken";
  }
}else{
  $response = "passwords don't match";
}
mysql_close();